/*
 *  CDCIDescriptor.cpp
 *  libavid
 *
 *  Created by Peter on 29.02.12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 */
#include "CDCIDescriptor.h"
#include "AStream.h"

A_IMPLEMENT_CLASS( 'CDCI', CDCIDescriptor, DIDDescriptor );

void CDCIDescriptor::readFromStream( AStream& str, const AObjDoc& objd )
{
	DIDDescriptor::readFromStream( str, objd );
	
	UInt8 tagMark, version;
	str.readPod( tagMark );
	str.readPod( version );
	TR_ASSERT( tagMark == 0x02 );
	TR_ASSERT( version == 0x02 );
	
	str.readPod( _horizontalSubsampling );
	str.readPod( _verticalSubsampling );
	str.readPod( _componentWidth );
	str.readPod( _colorSiting );
	str.readPod( _blackReferenceLevel );
	str.readPod( _whiteReferenceLevel );
	str.readPod( _colorRange );
	str.readPod( _offsetToFrameIndexes );
	
	str.readPod( tagMark );
	TR_ASSERT( tagMark == 0x03 );
}

#define TRACE_FIELD( x ) "\t" #x ": " << x << std::endl

void CDCIDescriptor::dump( std::ostream& str ) const
{
	str << "CDCIDescriptor {" << std::endl;
	
	str << "\t";
	DIDDescriptor::dump( str );
	
	str << TRACE_FIELD( _horizontalSubsampling );
	str << TRACE_FIELD( _verticalSubsampling );
	str << TRACE_FIELD( _componentWidth );
	str << TRACE_FIELD( _colorSiting );
	str << TRACE_FIELD( _blackReferenceLevel );
	str << TRACE_FIELD( _whiteReferenceLevel );
	str << TRACE_FIELD( _colorRange );
	str << TRACE_FIELD( _offsetToFrameIndexes );
	
	str << "}" << std::endl;
}